<template>
	<section>
		<div class="left">
			<el-tree 
				:data="treeData"
				:props="defaultProps" 
				node-key="orgSerialNo" ref="tree"
				@node-click="handleNodeClick">
			</el-tree>
		</div>
		<div class="right">
			<tong-ji-form @submitFrom="submitFrom" :activeName="activeName" ></tong-ji-form>
			<tong-ji-table :areaTime="areaTime" @gotoPage="gotoPage" :lableData="lableData" :tableData="tableData" :total="Number(total)" :activeName="activeName"></tong-ji-table>
			<a :href="download()">导出</a>
		</div>
		
	</section>
</template>

<script>
	import tongJiForm from './tongJiForm';
	import tongJiTable from './tongJiTable';
	import {apiDownload} from '../css_img_js/apiTongJi'
	export default{
		props:{
			activeName:'',
			lableData:'',
    		tableData:Array,
    		total:'',
    		treeData:'',
    		params:{},
		},
		components:{
			tongJiForm,
			tongJiTable
		},
		  data() {
		      return {
	            defaultProps: {
                    id:'orgSerialNo',
                    label: 'name',
                    children: 'organizationVos',
                },
                areaTime:'全部时间',/*选中的时间，显示在考核范围内*/
		      };
		    },
		methods:{
			handleNodeClick(val){/*选中当前部门*/
				this.$emit("chooseBran",val);
			},
			gotoPage(val){
				this.$emit("gotoPage",val);
			},
			submitFrom(val){
				console.log(val);
				switch (val.form2.groupByType){
					case "1":/*年度*/
						this.areaTime = val.form2.yearId;
						break;
					case "3":/*月度*/
						this.areaTime = val.value4;
						break;
					case "2":/*季度*/
						this.areaTime =val.form2.yearId+'-'+val.value5.label;
						break;
					default:
						break;
				}
				this.$emit("submitFrom",val);
			},
			download(){
				return apiDownload(this.params);
			}
			
		}
	}
</script>

<style scoped="scoped">
	.el-menu{
		width: 200px;
	}
	.left{
		width: 200px;
		display: inline-block;
	}
	.right{
		width: calc(100% - 200px);
		float: right;
	}
</style>